import AppPayment from '@/utils/platform/payment/provider/appPayment.js'

let service = null;

/**
 * 各个平台的初始化
 */
const init = async (platform) => {
	//普通H5平台
	if (platform === 'H5') {
		try {
			// provider = require('./provider/h5.js')
		} catch (e) {
			// ig
		}
	}
	//微信H5平台
	else if (platform === 'H5-WEIXIN') {
		try {
			// provider = require('./provider/h5Weixin.js')
		} catch (e) {
			// ig
		}
	}
	//微信小程序平台
	else if (platform === 'MP-WEIXIN') {
		try {
			// provider = require('./provider/mpWeixin.js')
			service = AppPayment;
		} catch (e) {
			// ig
		}
	}
	//APP平台
	else if (platform === 'App') {
		try {
			service = AppPayment;
		} catch (e) {
			// ig
		}
	}
	//默认啥都不做
	else {
		try {
			// provider = require('./provider/default.js')
		} catch (e) {
			// ig
		}
	}
};
/**
 * 支付
 */
const pay = async (options) => {
	return service.pay(options);
};

export default {
	init,
	pay
}